#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
char ma[1010][1010]={'\0'};
int main(void){
        string s;cin>>s;
        int numRows;cin>>numRows;
        int cnt=0;numRows--;
        while(1)
        {
            for(int j=0; ;j++)
            {
                for(int i=0;i<=numRows;i++)
                {
                    if(j%numRows==0)
                    {
                        ma[i][j]=s[cnt++];
                        if(cnt>s.size()) goto Break;
                    }
                    else{
                        if(i==numRows-(j%numRows)) ma[i][j]=s[cnt++];
                        if(cnt>s.size()) goto Break;
                    }
                }
            }
        }
        Break:
            string ans="";
            for(int i=0;i<=numRows;i++)
            {
                for(int j=0;j<1010;j++)
                {
                    if(ma[i][j]!='\0') ans+=ma[i][j];
                    cout<<ma[i][j]<<" ";
                }
                cout<<endl;
            }
        cout<<ans<<endl;

   	return 0;
}
